Mega Code Archive

Categories
1) Android
2) ASP.Net
3) ASP.Net Tutorial
4) C
5) C Tutorial
6) C#
7) C# Book
8) C# by API
9) C# Tutorial
10) C++
11) C++ Tutorial
12) Delphi
13) Flash ActionScript
14) Flex
15) Java
16) Java Book
17) Java by API
18) Java Tutorial
19) JavaScript DHTML
20) JavaScript Reference
21) JavaScript Tutorial
22) MSOfficeExcel 2007 Tutorial
23) MSOfficePowerPoint 2007 Tutorial
24) MSOfficeWord 2007 Tutorial
25) MSSQL
26) MSSQL Tutorial
27) MySQL
28) MySQL Tutorial
29) Oracle PLSQL
30) Oracle PLSQL Tutorial
31) Perl
32) Php
33) PostgreSQL
34) Python
35) Python Tutorial
36) Ruby
37) Silverlight
38) VB.Net
39) VB.Net by API
40) VB.Net Tutorial
41) Visual C++ .NET
42) VisualBasic Script
43) XML
44) XML Tutorial
 
MSSQL Tutorial
1) Aggregate Functions
2) Analytical Functions
3) CLR
4) Constraints
5) Cursor
6) Data Convert Functions
7) Data Types
8) Database
9) Date Functions
10) Index
11) Insert Delete Update
12) Math Functions
13) Procedure Function
14) Query
15) Sequence Indentity
16) Set Operations
17) String Functions
18) Subquery
19) System Functions
20) System Settings
21) System Tables Views
22) Table
23) Table Join
24) Transact SQL
25) Transaction
26) Trigger
27) User Role
28) View
29) XML
Date Functions
1) (DATEPART(dd, @date1) = DATEPART(dd, @date2))
2) (DATEPART(mm, @date1) = DATEPART(mm, @date2))
3) (DATEPART(yy, @date1) = DATEPART(yy, @date2)
4) A SELECT statement that computes the age of a Billing with DATEDIFF
5) A statement that changes the date format
6) Calculating the First Day of the Month
7) CHECK (entered_date = CURRENT_TIMESTAMP)
8) Combining this with DATEADD allows you to find out the month name in two months time
9) CONVERT(varchar,GETDATE(),113) dd Mmm yyyy hh
10) DATEADD adds a time interval to a date in order to arrive at the new date
11) DATEADD adds or subtract a number of days, months, or years from a specific date
12) DATEDIFF returns the difference between two dates as specified by datepart
13) DATENAME returns dates character string representation
14) DATEPART Function returns the integer value of the datepart specified
15) DATEPART returns part of a date as an integer value
16) Datetime DEFAULT CURRENT_TIMESTAMP
17) Days between two dates
18) Determine the date 90 days after April 29, 1988
19) Displaying the Integer Value For Part of a Date using DAY
20) Displaying the Integer Value For Part of a Date using MONTH
21) Displaying the Integer Value For Part of a Date using YEAR
22) Displaying the String Value for Part of a Date
23) Find difference in months between now and EndDate
24) Finding the Difference Between Two Dates
25) Finding the Last Day of the Month
26) GETDATE function returns the current system date and time of the server
27) Grouping by the Week by using datepart function
28) Identifying Weekday
29) IF DATEDIFF(dd, 7599,7500) = 0
30) Make sure month and day are two char long and build the date string
31) Returning the Current Date and Time GETUTCDATE()
32) SELECT @today = current_timestamp
33) Select CONVERT(varchar,GETDATE(),108) hh
34) Select CONVERT(varchar,GETDATE(),114) hh
35) Select CURRENT_TIMESTAMP
36) Select DATEADD(day, 1, 2002-09-30 11
37) SELECT DATEADD(day, 14, GETDATE())
38) Select DATEADD(hour, 1, 2002-09-30 11
39) Select DATEADD(minute, 1, 2002-09-30 11
40) Select DATEADD(month, -1, 2002-09-30 11
41) Select DATEADD(month, 1, 2002-09-30 11
42) Select DATEADD(quarter, 1, 2002-09-30 11
43) Select DATEADD(second, 1, 2002-09-30 11
44) Select DATEADD(week, 1, 2002-09-30 11
45) Select DATEADD(year, 1 5, 2002-09-30 11
46) Select DATEADD(year, 1, 2002-09-30 11
47) Select DATEDIFF(day, 2001-12-01, 2002-09-30)
48) Select DATEDIFF(day, 2002-09-30, 2001-12-01)
49) Select DATEDIFF(hour, 06
50) Select DATEDIFF(minute, 06
51) Select DATEDIFF(month, 2001-12-01, 2002-09-30)
52) Select DATEDIFF(quarter, 2001-12-01, 2002-09-30)
53) Select DATEDIFF(second, 06
54) Select DATEDIFF(week, 2001-12-01, 2002-09-30)
55) Select DATEDIFF(year, 2001-12-01, 2002-09-30)
56) SELECT DATEDIFF(yy, Dec 31, 1998, Jan 1, 1999)
57) SELECT DATEDIFF(yy, Jan 1, 1998, Dec 31, 1998)
58) Select DATENAME(day, 2002-09-30 11
59) Select DATENAME(dayofyear, 2002-09-30 11
60) Select DATENAME(hour, 2002-09-30 11
61) Select DATENAME(minute, 2002-09-30 11
62) Select DATENAME(month, 2002-09-30 11
63) Select DATENAME(month,2002-09-30)
64) Select DATENAME(quarter, 2002-09-30 11
65) Select DATENAME(second, 2002-09-30 11
66) Select DATENAME(week, 2002-09-30 11
67) Select DATENAME(weekday, 2002-09-30 11
68) Select DATENAME(year, 2002-09-30 11
69) Select DATEPART(day, 2002-09-30 11
70) Select DATEPART(dayofyear, 2002-09-30 11
71) SELECT DATEPART(dd, 7500)
72) SELECT DATEPART(dd, 7599)
73) Select DATEPART(hour, 2002-09-30 11
74) Select DATEPART(m,2002-09-30)
75) Select DATEPART(minute, 2002-09-30 11
76) Select DATEPART(month, 2002-09-30 11
77) Select DATEPART(quarter, 2002-09-30 11
78) Select DATEPART(second, 2002-09-30 11
79) Select DATEPART(week, 2002-09-30 11
80) Select DATEPART(weekday, 2002-09-30 11
81) SELECT DATEPART(weekday, CAST(20051004 AS DATETIME) + @@DATEFIRST)
82) Select DATEPART(year, 2002-09-30 11
83) Select DAY(2002-09-30)
84) Select GETDATE()
85) SELECT GETDATE() + 14
86) Select ISDATE(2002-09-30)
87) Select ISDATE(2002-09-31)
88) Select ISDATE(23
89) Select MONTH(2002-09-30)
90) Select YEAR(2002-09-30)
91) To change the first day value, you can use the SET DATEFIRST command
92) Use GetDate() function in where clause
93) Using SQL Servers First Day of the Week Setting
94) Values for the datepart parameter
95) Where DATEDIFF(WEEK, pubdate, GETDATE()) = 48
96) Where DATEPART(DAY, pubdate) BETWEEN 8 AND 14
97) WHERE DATEPART(WEEKDAY, pubdate) = 3
98) YEAR, MONTH, DAY